var ClassRoom = {
    newClassRoom:function(population,purpose){
        return{
            population:population,
            purpose:purpose
        }
    },
    givePurpose:function(cls){
        if(!isNaN(cls.purpose[0])){
            return cls.purpose.slice();
        }
        let pik = 0;
        let psk = Math.random();
        for(let i in cls.purpose){//概率分布
            pik+=cls.purpose[i].p;
            if(psk<=pik){//console.log(cls.purpose[i].purpose.slice())
                return cls.purpose[i].purpose.slice();
            }
        }
    }
}
function testNewClassRoom(times,population,from,to){
    let classRooms = [];
    for(let i =0;i<times;i++){
        classRooms.push(ClassRoom.newClassRoom(population,[i+1<=(times/2)?from:to]));
    }
    return classRooms;
}